<template>
  <div id="app">
    姓名：<input v-model.trim="msg" type="text" />
    <br />
    年龄：<input v-model.trim.number="age" type="number" />
    <br />
    身高：<input v-model.trim.number="height" type="number" />（米）
    <br />
    体重：<input v-model.trim.number="weight" type="number" />（公斤）
    <br />
    病史：<input v-model.trim="history" type="text" />
    <br />
    <br />
    <button @click="zd">诊断</button>
    <br />
    <p v-show="flag === false">
      患者{{ this.msg }} 的诊断结果：{{ this.zdjg }}
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "",
      age: "",
      height: "",
      weight: "",
      history: "",
      zdjg: "",
      flag: true,
    };
  },
  methods: {
    zd() {
      this.flag = false;
      const BMI = Math.pow(this.weight, 2) / Math.pow(this.height, 2);
      if (BMI <= 18.5) return (this.zdjg = `体重过轻`);
      else if (BMI <= 24.9) return (this.zdjg = `正常`);
      else if (BMI <= 29.9) return (this.zdjg = `体重过重`);
      else if (BMI > 29.9) return (this.zdjg = `肥胖`);
    },
  },
};
</script>

<style scoped>
</style>